gtk4.git
8 years agoRemove some more gtk_widget_get_content_size uses
Timm Bäder [Mon, 4 Dec 2017 11:42:52 +0000 (12:42 +0100)]
Remove some more gtk_widget_get_content_size uses

8 years agowidgetbowl: Add some more widget types
Timm Bäder [Sun, 3 Dec 2017 18:03:48 +0000 (19:03 +0100)]
widgetbowl: Add some more widget types

8 years agotestswitch: Remove unnecessary gtk_widget_show calls
Timm Bäder [Sat, 2 Dec 2017 10:27:02 +0000 (11:27 +0100)]
testswitch: Remove unnecessary gtk_widget_show calls

8 years agoimage: Stop using gtk_widget_get_content_size
Timm Bäder [Mon, 4 Dec 2017 11:14:21 +0000 (12:14 +0100)]
image: Stop using gtk_widget_get_content_size

8 years agopopover: Stop using gtk_widget_get_content_size
Timm Bäder [Thu, 23 Nov 2017 10:29:47 +0000 (11:29 +0100)]
popover: Stop using gtk_widget_get_content_size

8 years agospinner: Stop using gtk_widget_get_content_size
Timm Bäder [Sun, 3 Dec 2017 18:00:09 +0000 (19:00 +0100)]
spinner: Stop using gtk_widget_get_content_size

8 years agogsk: Remove gsk_render_node_set_scaling_filters()
Benjamin Otte [Sun, 3 Dec 2017 20:56:24 +0000 (21:56 +0100)]
gsk: Remove gsk_render_node_set_scaling_filters()

This is a leftover from the very early rendernode that we forgot to delete.

This can be seen by the fact that it is settable on an immutable object.

8 years agoUse Unicode quotation marks in new strings
Piotr Drąg [Sun, 3 Dec 2017 17:38:39 +0000 (18:38 +0100)]
Use Unicode quotation marks in new strings

See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772371

8 years agoUpdate POTFILES.in
Piotr Drąg [Sun, 3 Dec 2017 17:24:36 +0000 (18:24 +0100)]
Update POTFILES.in

8 years agoGDK W32: Remove stray debug code
Руслан Ижбулатов [Sun, 3 Dec 2017 06:08:44 +0000 (06:08 +0000)]
GDK W32: Remove stray debug code

I have no idea how this slipped into master (these two lines are not present
in the same commit that went into gtk-3-22).

8 years agodnd: Remove unused variables
Benjamin Otte [Sun, 3 Dec 2017 05:50:51 +0000 (06:50 +0100)]
dnd: Remove unused variables

8 years agoRemove GdkDragProtocol from the api
Matthias Clasen [Thu, 24 Aug 2017 21:40:16 +0000 (17:40 -0400)]
Remove GdkDragProtocol from the api

...together with apis that return it. We were not using this
information in GTK+ at all, so no need to provide it.

8 years agoDrop api that is only for unmanaged dnd
Matthias Clasen [Thu, 24 Aug 2017 18:30:47 +0000 (14:30 -0400)]
Drop api that is only for unmanaged dnd

These functions are not needed as public api anymore.

8 years agodnd: Handle rootwin drop in gdk
Matthias Clasen [Sun, 3 Dec 2017 05:22:25 +0000 (06:22 +0100)]
dnd: Handle rootwin drop in gdk

This lets us drop the only use of the drag protocol in gtk.

8 years agodnd: Remove much of the unmanaged dnd
Matthias Clasen [Wed, 23 Aug 2017 19:50:17 +0000 (15:50 -0400)]
dnd: Remove much of the unmanaged dnd

8 years agowayland: Add primary clipboard subclass
Benjamin Otte [Sun, 3 Dec 2017 04:39:08 +0000 (05:39 +0100)]
wayland: Add primary clipboard subclass

I decided to put this in a custom subclass, because then I could keep
the whole gtk primary protocol self-contained.

The other option would have been reusing GdkWaylandClipboard, but that
didn't seem worth it, especially because that code needs to interact
with the DND machinery, while the primary doesn't.

8 years agowayland: Implement taking over the clipboard
Benjamin Otte [Sun, 3 Dec 2017 02:51:43 +0000 (03:51 +0100)]
wayland: Implement taking over the clipboard

The clipboard is now complete.
That was fast.

8 years agowayland: Implement reading the clipboard
Benjamin Otte [Sun, 3 Dec 2017 01:48:17 +0000 (02:48 +0100)]
wayland: Implement reading the clipboard

We now keep track of what's in the clipboard and allow people to read
its contents.

8 years agowayland: Add skeleton for a GdkClipboardWayland
Benjamin Otte [Sat, 2 Dec 2017 20:54:36 +0000 (21:54 +0100)]
wayland: Add skeleton for a GdkClipboardWayland

Creates the source file and a custom subclass and makes sure it's used
by GDK.

8 years agogdk: Get rid of owner change events
Benjamin Otte [Sat, 2 Dec 2017 15:05:53 +0000 (16:05 +0100)]
gdk: Get rid of owner change events

They're unused now.

8 years agogtk: Remove GtkClipboard
Benjamin Otte [Sat, 2 Dec 2017 14:42:12 +0000 (15:42 +0100)]
gtk: Remove GtkClipboard

8 years agoicon-browser: Port to new clipboard
Benjamin Otte [Sat, 2 Dec 2017 14:41:22 +0000 (15:41 +0100)]
icon-browser: Port to new clipboard

8 years agogtk-demo: Port to GdkClipboard
Benjamin Otte [Sat, 2 Dec 2017 13:39:37 +0000 (14:39 +0100)]
gtk-demo: Port to GdkClipboard

8 years agoclipboard: Change image convenience APIs
Benjamin Otte [Sat, 2 Dec 2017 13:38:57 +0000 (14:38 +0100)]
clipboard: Change image convenience APIs

Don't use pixbufs anymore, use textures.

8 years agogdk: Add (de)serializers for GDK_TYPE_TEXTURE
Benjamin Otte [Sat, 2 Dec 2017 13:36:57 +0000 (14:36 +0100)]
gdk: Add (de)serializers for GDK_TYPE_TEXTURE

We want to use textures more, so we should be able to use them for
copy/paste and dnd.

8 years agox11: Handle case where clipboard was reclaimed quickly
Benjamin Otte [Fri, 1 Dec 2017 06:42:36 +0000 (07:42 +0100)]
x11: Handle case where clipboard was reclaimed quickly

When the reply to a TARGETS request comes in, the clipboard may already
be reclaimed by the local app. Deal with that case (in an ugly way,
strictly speaking we should use a cancellable here).

This happens for example at startup when the initial TARGETS requests
have not been answered until after the main widow popped up. And if such
a window immediately claims the primary clipboard (like when the initial
focus is inside an entry), this race will happen.

8 years agoentry: Port to GdkClipboard
Benjamin Otte [Fri, 1 Dec 2017 06:21:21 +0000 (07:21 +0100)]
entry: Port to GdkClipboard

8 years agox11: Implement storing the clipboard
Benjamin Otte [Fri, 1 Dec 2017 05:20:28 +0000 (06:20 +0100)]
x11: Implement storing the clipboard

8 years agox11: Implement MULTIPLE requests
Benjamin Otte [Fri, 1 Dec 2017 05:06:53 +0000 (06:06 +0100)]
x11: Implement MULTIPLE requests

8 years agotests: Don't crash if widgets go away before clipboard
Benjamin Otte [Fri, 1 Dec 2017 05:05:07 +0000 (06:05 +0100)]
tests: Don't crash if widgets go away before clipboard

Don't g_signal_connect() to the clipboard without protection - the
clipboard might outlast you and still emit signals.

8 years agox11: Introduce GdkX11PendingSelectionNotify
Benjamin Otte [Fri, 1 Dec 2017 01:53:47 +0000 (02:53 +0100)]
x11: Introduce GdkX11PendingSelectionNotify

This object tracks the SelectionNotifyEvent that has to be sent in
response to a SelectionRequest.

Currently it just looks like code reshuffling, but it's a prerequisite
for handling MULTIPLE, which requires to only send the notify after
every stream has writtten at least once.

But anyway, code is cleaner now, so it's a win!

8 years agox11: Split out a function
Benjamin Otte [Thu, 30 Nov 2017 23:02:12 +0000 (00:02 +0100)]
x11: Split out a function

This will be necessary for MULTIPLE handling.

8 years agomain: Implement storing all clipboards
Benjamin Otte [Thu, 30 Nov 2017 00:05:02 +0000 (01:05 +0100)]
main: Implement storing all clipboards

8 years agoapplication: Put shared code into a common function
Benjamin Otte [Wed, 29 Nov 2017 23:09:37 +0000 (00:09 +0100)]
application: Put shared code into a common function

8 years agoclipboard: Add infrastructure to store clipboards
Benjamin Otte [Wed, 29 Nov 2017 22:23:36 +0000 (23:23 +0100)]
clipboard: Add infrastructure to store clipboards

Clipboard managers will be so happy once the backends actually implement
it!

8 years agocontentprovider: Add ref_storable_formats()
Benjamin Otte [Wed, 29 Nov 2017 09:07:52 +0000 (10:07 +0100)]
contentprovider: Add ref_storable_formats()

This is to be used for advocating to clipboard managers.

8 years agofilechooserwidget: Port to new clipboard
Benjamin Otte [Wed, 29 Nov 2017 08:52:38 +0000 (09:52 +0100)]
filechooserwidget: Port to new clipboard

We use the new GDK_TYPE_FILE_LIST here.

8 years agogdk: Add GDK_TYPE_FILE_LIST with serializers
Benjamin Otte [Wed, 29 Nov 2017 08:37:50 +0000 (09:37 +0100)]
gdk: Add GDK_TYPE_FILE_LIST with serializers

This is a GSList of GFile and we want it so we can operate with lists of
files and text/uri-list.

I chose GSList over GList because that's what the GtkFileChooser API
uses, too.

8 years agogdk: Add serializers and deserializers for GFile
Benjamin Otte [Wed, 29 Nov 2017 07:13:06 +0000 (08:13 +0100)]
gdk: Add serializers and deserializers for GFile

in particular, support:
GFile <=> text/uri-list
GFile  => text/plain

8 years agotests: Improve formats list for testclipboard2
Benjamin Otte [Tue, 28 Nov 2017 03:00:31 +0000 (04:00 +0100)]
tests: Improve formats list for testclipboard2

8 years agolabel: Port to new clipboard
Benjamin Otte [Tue, 28 Nov 2017 01:36:16 +0000 (02:36 +0100)]
label: Port to new clipboard

8 years agotextview: Redo clipboard handling
Benjamin Otte [Tue, 28 Nov 2017 01:09:21 +0000 (02:09 +0100)]
textview: Redo clipboard handling

Instead of using GtkClipboard and handling everything ourselves, we now
put GtkTextBuffer into the GdkClipboard and register (de)serializers for
text/plain.

8 years agogdk: Add gdk_content_formats_new_for_gtype()
Benjamin Otte [Tue, 28 Nov 2017 01:02:06 +0000 (02:02 +0100)]
gdk: Add gdk_content_formats_new_for_gtype()

Many places create formats for a single tpye, so make it easy for them
to get this without having to create a builder first.

8 years agogdk: Allow setting task data on (de)serializers
Benjamin Otte [Tue, 28 Nov 2017 00:58:56 +0000 (01:58 +0100)]
gdk: Allow setting task data on (de)serializers

This mirrors GTask.

8 years agogtk-demo: Port clipboards example to new clipboard
Benjamin Otte [Sun, 26 Nov 2017 21:39:47 +0000 (22:39 +0100)]
gtk-demo: Port clipboards example to new clipboard

8 years agorecentchooser: Port to GdkClipboard
Benjamin Otte [Sun, 26 Nov 2017 06:54:55 +0000 (07:54 +0100)]
recentchooser: Port to GdkClipboard

8 years agolinkbutton: Port to GdkClipboard
Benjamin Otte [Sun, 26 Nov 2017 06:38:12 +0000 (07:38 +0100)]
linkbutton: Port to GdkClipboard

8 years agoa11y: Port to GdkClipboard
Benjamin Otte [Sun, 26 Nov 2017 06:35:19 +0000 (07:35 +0100)]
a11y: Port to GdkClipboard

8 years agowidget: Add gtk_widget_get_clipboard()
Benjamin Otte [Sat, 25 Nov 2017 22:55:34 +0000 (23:55 +0100)]
widget: Add gtk_widget_get_clipboard()

... and gtk_widget_get_primary_clipboard().

They both give out the new GdkClipboard.

8 years agowidget: gtk_widget_get_clipboard => gtk_widget_get_old_clipboard
Benjamin Otte [Sat, 25 Nov 2017 22:20:16 +0000 (23:20 +0100)]
widget: gtk_widget_get_clipboard => gtk_widget_get_old_clipboard

Just rename the function, so the previous one can be used for the
new clipboard.

8 years agotests: Open a 2nd display in testclipboard2
Benjamin Otte [Sat, 25 Nov 2017 21:54:32 +0000 (22:54 +0100)]
tests: Open a 2nd display in testclipboard2

This allows testing local transfer of data as well as remote transfer
(by transferring data between clipboards of both Displays).

8 years agox11: Implement claiming the X Selection with the clipboard
Benjamin Otte [Sat, 25 Nov 2017 20:59:39 +0000 (21:59 +0100)]
x11: Implement claiming the X Selection with the clipboard

... and of course support writing to other apps.

8 years agotests: Add possibility to set invalid UTF-8 and clear clipboard
Benjamin Otte [Sat, 25 Nov 2017 07:37:03 +0000 (08:37 +0100)]
tests: Add possibility to set invalid UTF-8 and clear clipboard

8 years agox11: Add gdk_x11_display_get_max_request_size()
Benjamin Otte [Sat, 25 Nov 2017 00:25:31 +0000 (01:25 +0100)]
x11: Add gdk_x11_display_get_max_request_size()

There's multiple places in the clipboard code where I need it, so make
it a custom function.

8 years agoclipboard: Allow claiming the clipboard to fail
Benjamin Otte [Fri, 24 Nov 2017 19:42:40 +0000 (20:42 +0100)]
clipboard: Allow claiming the clipboard to fail

Also make clipboard_claim() a vfunc so backends can override it.

Because the whole operation a vfunc, backends have the option of adding
code before the actual claim is done and potentially even fail or do
something after the successful claim.

8 years agogdkcontentformats: Change the matching API
Benjamin Otte [Fri, 24 Nov 2017 10:34:19 +0000 (11:34 +0100)]
gdkcontentformats: Change the matching API

Instead of having just one function that has the gtype and mime type as
out arguments, have 3 functions: 1 that finds any match, 1 that finds a
GType match and one for a mime type match.

This makes the API way more convenient to use.

8 years agoclipboard: Add serialization
Benjamin Otte [Fri, 24 Nov 2017 10:15:51 +0000 (11:15 +0100)]
clipboard: Add serialization

This completes the local clipboard code.

8 years agoclipboard: Implement local fallback clipboard transfers
Benjamin Otte [Fri, 24 Nov 2017 09:13:23 +0000 (10:13 +0100)]
clipboard: Implement local fallback clipboard transfers

This requires implementing a "pipe" so we can have 2 streams running:
  contentprovider => serializer => outputstream
  inputstream => deserializer => reader
And the pipe shoves the data from the outputstream into the inputstream.

8 years agoclipboard: Introduce GdkContentProvider
Benjamin Otte [Fri, 24 Nov 2017 05:17:37 +0000 (06:17 +0100)]
clipboard: Introduce GdkContentProvider

GdkContentProvider is the object that represents local data in the
clipboard.

This patch only introduces the object and adds the clipboard properties,
it does not yet provide a way for the actual implementations to access
it.

The only access that is implemented is the local shortcut GValue access.

8 years agoclipboard: Make value getters set the passed in value
Benjamin Otte [Fri, 24 Nov 2017 05:07:09 +0000 (06:07 +0100)]
clipboard: Make value getters set the passed in value

Don't return a const GValue, that's ugly API. Instead require people to
pass in a preinitialized GValue and set that one.

8 years agox11: Improve fallbacks for text
Benjamin Otte [Thu, 23 Nov 2017 00:59:19 +0000 (01:59 +0100)]
x11: Improve fallbacks for text

(1) Try all passed in formats in order if one of them fails.
(2) Don't blindly accept all formats, make sure they are mime types
(3) Add a bunch of special non-mime types that plug converters to
    get to mime types

8 years agoclipboard: Add gdk_clipboard_read_text_async()
Benjamin Otte [Wed, 22 Nov 2017 13:19:02 +0000 (14:19 +0100)]
clipboard: Add gdk_clipboard_read_text_async()

Also add deserializers for G_TYPE_STRING.

8 years agoclipboard: Add gdk_clipboard_read_pixbuf_async()
Benjamin Otte [Wed, 22 Nov 2017 12:21:25 +0000 (13:21 +0100)]
clipboard: Add gdk_clipboard_read_pixbuf_async()

8 years agogdk: Im[plement content deserializing
Benjamin Otte [Wed, 22 Nov 2017 09:44:30 +0000 (10:44 +0100)]
gdk: Im[plement content deserializing

Add infrastructure to do GInputStream => GType conversions. Use that to
implement gdk_clipboard_read_value() which reads into GValues.

8 years agox11: Improve debugging output for selection input stream
Benjamin Otte [Wed, 22 Nov 2017 09:43:04 +0000 (10:43 +0100)]
x11: Improve debugging output for selection input stream

8 years agoclipboard: Refactor gdk_clipboard_read() to be async
Benjamin Otte [Wed, 22 Nov 2017 08:25:35 +0000 (09:25 +0100)]
clipboard: Refactor gdk_clipboard_read() to be async

This allows us not just to pass any mime type to the read function, but
it also makes it possible to pass multiple mime types and the clipboard
can then try them in order until it finds a supported one.

This is so far not implemented though.

8 years agox11: Use async queue and implement sync reads on selections stream
Benjamin Otte [Mon, 20 Nov 2017 20:29:32 +0000 (21:29 +0100)]
x11: Use async queue and implement sync reads on selections stream

Turns out, way too many async operations are implemented by running the
sync operation in a thread. The easiest solution is to support that is
to use a GAsyncQueue for the buffers and deadlock if called from the
main thread.

8 years agotests: Add a new test app for GdkClipboard
Benjamin Otte [Mon, 20 Nov 2017 01:07:31 +0000 (02:07 +0100)]
tests: Add a new test app for GdkClipboard

8 years agoclipboard: Implement gdk_clipboard_read()
Benjamin Otte [Mon, 20 Nov 2017 01:06:21 +0000 (02:06 +0100)]
clipboard: Implement gdk_clipboard_read()

8 years agox11: Implement INCR reads
Benjamin Otte [Sun, 19 Nov 2017 19:52:36 +0000 (20:52 +0100)]
x11: Implement INCR reads

8 years agox11: Various clipboard cleanups
Benjamin Otte [Sun, 19 Nov 2017 18:52:07 +0000 (19:52 +0100)]
x11: Various clipboard cleanups

(1) Turn X11 clipboard event handling into a regular filter function
(2) Maintain a timestamp in the clipboard, so we can pass it when
    querying selections.

8 years agoclipboard: Add gdk_clipboard_claim_remote()
Benjamin Otte [Sun, 19 Nov 2017 18:18:22 +0000 (19:18 +0100)]
clipboard: Add gdk_clipboard_claim_remote()

This allows the remote clipboard to take over. The X11 clipboard already
does that.

8 years agox11: Add an initial clipboard implementation
Benjamin Otte [Sun, 19 Nov 2017 17:06:13 +0000 (18:06 +0100)]
x11: Add an initial clipboard implementation

This does nothing but download the targets and debug-print them.

8 years agogdk: A GdkClipboard API draft
Matthias Clasen [Thu, 29 May 2014 03:55:53 +0000 (23:55 -0400)]
gdk: A GdkClipboard API draft

This commit adds a GdkClipboard object which is intended to
replace GtkClipboard, eventually.

8 years agoGDK W32: Plug a resource leak
Руслан Ижбулатов [Mon, 4 Sep 2017 14:42:11 +0000 (14:42 +0000)]
GDK W32: Plug a resource leak

Ensure that surfaces allocated in the impl are destroyed in finalize()

https://bugzilla.gnome.org/show_bug.cgi?id=787089

8 years agoUpdate Polish translation
Piotr Drąg [Sat, 2 Dec 2017 17:45:33 +0000 (18:45 +0100)]
Update Polish translation

8 years agodnd: Add gtk_drag_set_icon_texture()
Benjamin Otte [Sat, 2 Dec 2017 13:28:05 +0000 (14:28 +0100)]
dnd: Add gtk_drag_set_icon_texture()

8 years agoselection: Add texture getter/setter
Benjamin Otte [Sat, 2 Dec 2017 13:25:35 +0000 (14:25 +0100)]
selection: Add texture getter/setter

8 years agoimage: Add gtk_image_new_from_texture()
Benjamin Otte [Sat, 2 Dec 2017 00:29:36 +0000 (01:29 +0100)]
image: Add gtk_image_new_from_texture()

Docs and header knew about this function.
There just was no implementation.

8 years agoimage: Store pixbufs as textures, not surfaces
Benjamin Otte [Fri, 1 Dec 2017 14:22:24 +0000 (15:22 +0100)]
image: Store pixbufs as textures, not surfaces

8 years agovulkan: Fix mask shader to premultiply color
Benjamin Otte [Fri, 1 Dec 2017 13:44:09 +0000 (14:44 +0100)]
vulkan: Fix mask shader to premultiply color

The inColor wasn't premultiplied, so the resulting colors were wrong
with translucent borders.

8 years agovulkan: Fix border shader to premultiply color
Benjamin Otte [Fri, 1 Dec 2017 13:32:38 +0000 (14:32 +0100)]
vulkan: Fix border shader to premultiply color

The inColor wasn't premultiplied, so the resulting colors were wrong
with translucent borders.

8 years agoGDK W32: Remove an unnecessary type check
Руслан Ижбулатов [Sun, 26 Nov 2017 13:15:53 +0000 (13:15 +0000)]
GDK W32: Remove an unnecessary type check

No idea why it's here, the hash table can store any kind of data,
there's no reason why it wouldn't be able to store an old X string type.
Might be a holdout from the old days, when strings were handled in
a special way (stored directly in the clipboard?).

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoGDK W32: Make sure drag source window is not NULL
Руслан Ижбулатов [Sun, 26 Nov 2017 13:10:44 +0000 (13:10 +0000)]
GDK W32: Make sure drag source window is not NULL

This prevents GTK from throwing a bunch of warnings when it tries
to get drag source window -> screen of that window -> ipc widget for that screen,
and then tries to attach a signal handler to that widget.

Specifically, this happens when we get a DnD move from another
application.

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoGDK W32: Special handling for DELETE requests
Руслан Ижбулатов [Sun, 26 Nov 2017 13:06:24 +0000 (13:06 +0000)]
GDK W32: Special handling for DELETE requests

1) Ensure that any DELETE requests from the target are sent to GDK, even if
   both the source and the target are in the same process and it
   is therefore possible to use a shortcut and call the handler directly
   in GTK layer
2) Ensure that target GDK doesn't do anything when GTK asks it to send
   a DELETE request, just report back immediately (the code up the stack
   does not check for successfullness when request is DELETE, so not giving
   it any data is OK).

The source code already synthesizes a DELETE request, so that side is
also taken care of.

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoGDK W32: Preserve the target value for change_property()
Руслан Ижбулатов [Sun, 26 Nov 2017 00:21:22 +0000 (00:21 +0000)]
GDK W32: Preserve the target value for change_property()

We need to know the target atom value to know when we need to
do something with side-effects (since side-effects are expressed via
special target values). Previously, the code side-stepped that by looking
at the data type (which was rather unique for the one side-effect
target that we supported, signalled by the TARGETS target),
but for the DELETE target that seems to be no longer an option, hence the new
field to carry this information past the convert_selection() routine.

This prevents GDK from throwing a warning when trying to convert
a DELETE target, which has no format or data objects set.

The side-effects for the DELETE target happen earlier, in GTK layer.
By the point it gets to change_property(), it's a no-op.

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoFix a nefarious typo
Руслан Ижбулатов [Sat, 25 Nov 2017 17:04:48 +0000 (17:04 +0000)]
Fix a nefarious typo

8 years agoGDK W32: Ensure that selection request is processed
Руслан Ижбулатов [Mon, 18 Sep 2017 16:49:11 +0000 (16:49 +0000)]
GDK W32: Ensure that selection request is processed

To do that, run the message loop for one second or until the side-effect
of running the selection request handler is achieved (as opposed to
running it until the event is no longer queued).

The disavantage of this method is that if the event handling is
somehow missed (due to a variety of reasons - after all, it's not
a straight path from an event being queued to property_change()
being called), this will loop for one second. Since we do process
events during that time, this will not hang the application, but
might still restrict some of the functionality.

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoGDK W32: Refuse to release mouse grab while in DnD mode
Руслан Ижбулатов [Thu, 14 Sep 2017 17:43:38 +0000 (17:43 +0000)]
GDK W32: Refuse to release mouse grab while in DnD mode

Handle WM_CANCELMODE and do nothing in response to it when DnD is
active. Otherwise pass it to DefWindowProc, which will call ReleaseCapture()
on our behalf.
This prevents us from losing mouse capture when alt-tabbing during DnD
(this includes the feature of Windows Explorer where dragging stuff over
a window button in the taskbar causes that window to receive focus, i.e.
keyboardless alt-tabbing).

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoGDK W32: Update layered windows on opacity changes
Руслан Ижбулатов [Sat, 2 Sep 2017 15:25:36 +0000 (15:25 +0000)]
GDK W32: Update layered windows on opacity changes

Without this patch layered windows are only updated when they are moved
by the user or then their contents changes. This patch adds opacity
changes to the list of things that make GDK update a window. Without this
windows that don't redraw and are not moved by the used (DnD drag indicator
windows, for example) don't change their opacity.

(This commit is cherry-picked from the gtk-3-22 branch)

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoW32: Massive W32 DnD fix
Руслан Ижбулатов [Sat, 19 Aug 2017 12:06:27 +0000 (12:06 +0000)]
W32: Massive W32 DnD fix

Massive changes to OLE2 DnD protocol, which was completely broken before:
* Keep GdkDragContext and OLE2 objects separate (don't ref/unref them
  together, don't necessarily create them together).
* Keep IDataObject formats in the object itself, not in a global variable.
* Fix getdata() to look up the request target in its format list, not in the
  global hash table
* Create target GdkDragContext on each drag_enter, destroy it on drag_leave,
  whereas IDropTarget is created when a window becomes a drag destination
  and is re-used indefinitely.
* Query the source IDataObject for its supported types, cache them in the
  target (!) context. This is how GTK+ works, honestly.
* Remember current_src_object when we initiate a drag, to be able
  to detect later on that the data object is ours and use a
  shortcut when querying targets
* Make sure GDK_DRAG_MOTION is only sent when something changes
* Support GTK drag cursors
* Ensure that exotic GTK clipboard formats are registered
  (but try to avoid registering formats that can't be used between applications).
* Don't enumerate internal formats
* Ensure that DnD indicator window can't accept drags or receive any kind of input
  (use WS_EX_TRANSPARENT).
* Remove unneeded indentation in _gdk_win32_dnd_do_dragdrop()
* Fix indentation in gdk_win32_drag_context_drop_finish()
* Remove obsolete comments in _gdk_win32_window_register_dnd()
* Check for DnD in progress when processing WM_KILLFOCUS, don't emit a grab
  break event in such cases (this allows alt-tabbing while DnD is in progress,
  though there may be lingering issues with focus after dropping...)
* Support Shell ID List -> text/uri-list conversion, now it's possible
  to drop files (dragged from Explorer) on GTK+ applications
* Explicitly use RegisterClipboardFormatA() when we know that the string
  is not in unicode. Otherwise explicitly use RegisterClipboardFormatW()
  with a UTF8->UTF16 converted string
* Fix _gdk_win32_display_get_selection_owner() to correctly bail
  when selection owner HWND is NULL (looking up GdkWindow for NULL
  HWND always succeeds and returns the root window - not the intended
  effect)
* More logging
* Send DROP_FINISHED event after DnD loop ends
* Send STATUS event on feedback
* Move GetKeyboardState() and related code into _gdk_win32_window_drag_begin(),
  so that it's closer to the point where last_pt and start_pt are set
* Use & 0x80 to check for the key being pressed. Windows will set low-order bit
  to 1 for all mouse buttons to indicate that they are toggled, so simply
  checking for the value not being 0 is not enough anymore.
  This is probably a new thing in modern W32 that didn't exist before
  (OLE2 DnD code is old).
* Fixed (hopefully) and simplified HiDPI parts of the code.

Also adds managed DnD implementation for W32 GDK backend (for both
OLE2 and LOCAL protocols). Mostly a copy of the X11 backend code, but
there are some minor differences:
* doesn't use drag_window field in GdkDragContext,
  uses the one in GdkWin32DragContext exclusively
* subtracts hotspot offset from the window coordinates when showing
  the dragback animation
* tries to consistently support scaling and caches the scale
  in the context
* Some keynav code is removed (places where grabbing/ungrabbing should
  happen is marked with TODOs), and the rest is probably inert.

Also significantly changes the way selection (and clipboard) is handled
(as MSDN rightly notes, the handling for DnD and Clipboard
 formats is virtually the same, so it makes sense to handle
 both with the same code):
* Don't spam GDK_OWNER_CHANGE, send them only when owner
  actually changes
* Open clipboard when our process becomes the clipboard owner
  (we are doing it anyway, to empty the clipboard and *become* the owner),
  and then don't close it until a scheduled selection request event
  (with TARGETS target) is received. Process that event by announcing
  all of our supported formats (by that time add_targets() should have
  been called up the stack, thus the formats are known; just in case,
  add_targets() will also schedule a selection request, if one isn't
  scheduled already, so that late-coming formats can still be announced).
* Allow clipboard opening for selection_convert() to be delayed if it
  fails initially.
* The last two points above should fix all the bugs about GTK+ rising
  too much ruckus over OpenClipboard() failures, as owner change
  *is allowed* to fail (though not all callers currently handle
  that case), and selection_convert() is asynchronous to begin with.
  Still, this is somewhat risky, as there's a possibility that the
  code will work in unexpected ways and the clipboard will remain open.
  There's now logging to track the clipboard being opened and closed,
  and a number of failsafes that try to ensure that it isn't kept open
  for no reason.
* Added copious notes on the way clipboard works on X11, Windows and GDK-W32,
  also removed old comments in DnD implementation, replaced some of them
  with the new ones
* A lot of crufty module-global variables are stuffed into a singleton
  object, GdkWin32Selection. It's technically possible to make it a
  sub-object of the Display object (the way Wayland backend does),
  but since Display object on W32 is a singleton anyway... why bother?
* Fixed the send_change_events() a bit (was slightly broken in one of the
  previous iterations)
* Ensure that there's no confusion between selection conversion (an artifact
  term from X11) and selection transmutation (changing the data to be W32-compatible)
* Put all the transmutation code and format-target-matching code into gdkselection-win32.c,
  now this code isn't spread across multiple files.
* Consequently, moved some code away from gdkproperty-win32.c and gdkdnd-win32.c
* Extensive format transmutation checks for OLE2 DnD and clipboard.
  We now keep track of which format mappings are for transmutations,
  and which aren't (for example, when formats are passed as-is, or when
  a registered name is just an alias)
* Put transmutation code into separate functions

* Ensure that drop target keeps a format->target map for supported formats,
  this is useful when selection_convert() is called, as it only receives a
  single target and no hints on the format from which the data should
  be transmuted into this target.
* Add clear_targets() on W32, to de called by GTK
* Use g_set_object() instead of g_ref_object() where it is allowed.
* Fix indentation (and convert tabs to spaces), remove unused variables

(This commit is cherry-picked from the gtk-3-22 branch)

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoGDK W32: Don't leak the atom name string
Руслан Ижбулатов [Tue, 22 Aug 2017 14:23:14 +0000 (14:23 +0000)]
GDK W32: Don't leak the atom name string

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoGDK W32: Fix a typo in OLE2 DnD code
Руслан Ижбулатов [Tue, 15 Aug 2017 13:12:43 +0000 (13:12 +0000)]
GDK W32: Fix a typo in OLE2 DnD code

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoOnly register application/x-rootwindow-drop on X11
Руслан Ижбулатов [Tue, 15 Aug 2017 13:07:01 +0000 (13:07 +0000)]
Only register application/x-rootwindow-drop on X11

application/x-rootwindow-drop is not useful anywhere else,
so put it under #ifdef GDK_WINDOWING_X11

On W32 this prevents toplevels from automatically becoming valid
drop targets with a useless drop type.

(This commit is cherry-picked from the gtk-3-22 branch)

https://bugzilla.gnome.org/show_bug.cgi?id=786509

8 years agoGDK W32: More flexible modal operation mode
Руслан Ижбулатов [Fri, 11 Aug 2017 07:00:41 +0000 (07:00 +0000)]
GDK W32: More flexible modal operation mode

Instead of using a boolean to indicate a modal operation being in progress,
use a set of flags, and allow these to be set and unset independently.

Specifically, this allows WM_CAPTURECHANGED handler to only act when a drag-move or
drag-resize modal operation is in progress, and ignore DND (which can also cause
WM_CAPTURECHANGED to be posted). This avoids a crash due to assertion failure when
OLE2 DND code tries to end a modal operation that was already ended by the WM_CAPTURECHANGED
handler.

(This commit is cherry-picked from the gtk-3-22 branch)

https://bugzilla.gnome.org/show_bug.cgi?id=786121

8 years agoGDK W32: fix monitor pruning code
Руслан Ижбулатов [Thu, 23 Nov 2017 07:15:28 +0000 (07:15 +0000)]
GDK W32: fix monitor pruning code

Decrement the counter for each removed element, otherwise we skip
one element every time we remove one. Also, no need for continue here.

8 years agoGDK W32: Correctly report window position in HiDPI mode
Руслан Ижбулатов [Fri, 29 Sep 2017 12:50:03 +0000 (12:50 +0000)]
GDK W32: Correctly report window position in HiDPI mode

Window position returned by get_frame_extents() should be scaled.

Also take this opportunity to apply the same rounding that X11 backend
applies.

https://bugzilla.gnome.org/show_bug.cgi?id=788053

8 years agoGDK-Win32: Fix AeroSnap on HiDPI
Chun-wei Fan [Tue, 8 Aug 2017 14:19:45 +0000 (22:19 +0800)]
GDK-Win32: Fix AeroSnap on HiDPI

Commit 1d0fad3 revealed that there were some assumptions made that were
actually to compensate for the bug fixed by that commit, so we need to
remove those assumptions as they would result in AerSnap to not work
properly on HiDPI screens.

Also re-do how we set the x and y positions of our GdkWindow, so that we
are more consistent across the board when we go between a GDK window
coordinate and a Windows API window cooredinate.

This would also simplify the code a bit.

https://bugzilla.gnome.org/show_bug.cgi?id=785999

8 years agoGDK W32: Handle drivers that do not send WT_CSRCHANGE after WT_PROXIMITY
Руслан Ижбулатов [Fri, 10 Feb 2017 10:49:00 +0000 (10:49 +0000)]
GDK W32: Handle drivers that do not send WT_CSRCHANGE after WT_PROXIMITY

Some drivers don't do that (not sure whether that is the correct behaviour
or not). Remember each WT_PROXIMITY with LOWORD(lParam) != 0 that we get,
then look for a WT_CSRCHANGE. If WT_CSRCHANGE doesn't come, but a WT_PACKET
does, assume that this device is the one that sent WT_PROXIMITY.

Also include fallback code to ensure that WT_PACKETs for an enabled device
disable the system pointer, because WT_PROXIMITY handler might have
enabled it by mistake, since it's not possible to know which device left
the proximity (it might have been a disabled device).

https://bugzilla.gnome.org/show_bug.cgi?id=778328

8 years agoGDK W32: Apply HiDPI scale properly to monitors
Руслан Ижбулатов [Fri, 17 Feb 2017 15:59:32 +0000 (15:59 +0000)]
GDK W32: Apply HiDPI scale properly to monitors

Previously HiDPI scale was retrieved and applied too late in the initialization
process to affect monitor size and monitor workarea size, but the code that
initializes these sizes *did* try to use the scale, even though it was always
getting scale=1.

To fix this, move the too-late code into monitor enumeration routine.
This also fixes a probable semantic bug where width and height were divided
by scale, again.

Now monitor and workarea should be in application pixels (i.e. divided by scale),
as intended.

https://bugzilla.gnome.org/show_bug.cgi?id=778835